﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace DotNetExtensions.AspNet.Helpers
{
    public class PathHelper
    {
        public static string Temp
        {
            get
            {
                string temp = Path.GetTempPath();
                if (!Directory.Exists(temp)) Directory.CreateDirectory(temp);

                return temp;
            }
        }

        public static string GetUrlFileName(string url)
        {
            if (string.IsNullOrEmpty(url) || url.IndexOf('/') == -1) return url;

            string[] splits = url.Split('/');

            string last = splits.Last();

            if (last.IndexOf('.') == -1) return last;

            return last.Substring(0, last.LastIndexOf('.'));
        }
    }
}
